<form method="post" action="__ACTION__" data-validate="true" data-continue="true" data-submit="ajax" class="form-horizontal edit-form">
  <div class="form-group">
	  <div class="form-item">
		  <div class="control-group">
		    <label class="control-label must">优惠卷名称</label>
		    <div class="controls">
		      <input class="required" type="text" name="title" maxlength="15" placeholder="最多15个字符"{$data['type'] == 2 ? ' disabled="disabled"' : ''}>
		    </div>
		  </div>
	  	  
	  	   <div class="control-group">
					            <label class="control-label must">发放总量</label>
					            <div class="controls">
					                <label class="radio inline">
					                  <input type="text" name="total" value="0" style=width:100px;margin-left:-20px;">
					                </label>
					                <span style="color:#ccc;font-size:13px;">(0 代表不限至)</span>
					            </div>
	        </div>
	  	  
	  	  <div class="control-group">
		    <label class="control-label must">面值</label>
		    <div class="controls">
		     <input type="text" name="value" maxlength="15" style="width:80px";>
		     <label class="checkbox inline"><input type="checkbox" >随机</label>
		    <input type="text" name="sjz" id="click" maxlength="15" style="width:80px;display:none;";>
		    </div>
		  </div>
	  	  
	  	  
	  	  
		   <div class="control-group">
					            <label class="control-label must">使用门槛</label>
					            <div class="controls">
					                <label class="radio inline">
					                  满<input type="text" name="meet" value="0" style="width: 100px;">
					                   	  元可使用
					                </label>
									<span style="color:#ccc;font-size:13px;">(0 代表不限至)</span>
					            </div>
	        </div>
	        
	        <div class="control-group">
								<label class="control-label">可使用商品</label>
								<div class="controls js_is_virtual">
									<label class="radio inline">
										<input class="yc" type="radio" name="range_type" value="0" checked="checked">全店通用<span class="gray"></span>
									</label>
									<label class="radio inline">
										<input class="zdsp" type="radio" name="range_type" value="1"}>指定商品<span class="gray"></span>
									</label>
								</div>
							</div>

		<button id="tk" style="display:none";margin-left:280px;margin-top:-15px;" type='button' class='btn btn-default' data-toggle='modal'  data-target='#add_info'><i class="icon-plus"></i>添加</button>

	  </div>
	  
	  <div class="form-item">
		<div class="control-group">
					<label class="control-label must">生效时间</label>
					<div class="controls">
						<div class="input-append date" data-format="yyyy-MM-dd hh:mm:ss">
							<input type="text" required="required" name="start_time" value=""style="width: 130px">
							<span class="add-on"><i class="icon-th"></i></span>
						</div>
					</div>
			</div>
			
			 <div class="control-group">
					<label class="control-label must">过期时间</label>
					<div class="controls">
						<div class="input-append date" data-format="yyyy-MM-dd hh:mm:ss">
							<input type="text" required="required" name="end_time" value=""style="width: 130px">
							<span class="add-on"><i class="icon-th"></i></span>
						</div>
					</div>
			</div>
		  
		  <div class="control-group">
		    <label class="control-label must">每人限领</label>
		    <div class="controls">
		        <select name="quota" id="city_id"  required="required" class="required" data-county="#county_id" data-selected="{$data.city_id}">
		        <option value="">请选择</option>
				<option value="0">无限制</option>
				<option value="1">1张</option>
				<option value="2">2张</option>
				<option value="3">3张</option>
				<option value="4">4张</option>
				<option value="5">5张</option>
				<option value="10">10张</option>
		        
		        </select>
		    </div>
	  	  </div>
		  
		  <div class="control-group">
		    <label class="control-label must">优惠卷类型</label>
		    <div class="controls">
		        <select name="type" id="city_id"  class="required" data-county="#county_id" data-selected="{$data.city_id}">
		        <option value="">请选择</option>
				<option value="1">优惠卷</option>
				<option value="2">优惠码</option>
				<option value="3">代金卷</option>
				<option value="4">满减活动</option>
				<option value="5">限时折扣</option>
				 </select>
		    </div>
		  </div>
		  	
		  
	  </div>
  </div>
 	<div class="form-group">
 		<div class="form-item">
			<div class="control-group">
			    <label class="control-label">使用说明</label>
			    <div class="controls">
			      <textarea rows="5" style="width:704px;" name="notice" maxlength="300" placeholder="最多300个字符">{$data.desc}</textarea>
			    </div>
			  </div>
 		</div>
	</div>
	<div class="form-actions">
	  <button type="submit" class="btn btn-primary">保存</button>
	  <button type="button" class="btn">取消</button>
	</div>
</form>

 <div class="modal fade" id="add_info" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">添加商品</h4>
            </div>
            <div class="modal-body">
           <!-- 表格 -->
			<table id="table" data-toggle="gridview" class="table table-hover" data-url="__ACTION__" data-toolbar="">
				<thead>
					<tr>
						<th data-width="40" data-checkbox="true"></th>
						<th data-field="title" data-formatter="formatter_title" data-sortable="true">商品</th>
						<th data-width="90" data-field="stock" data-align="center" data-sortable="true">库存</th>
					</tr>
				</thead>
			</table>
            </div>
            <div class="modal-footer">
             <button type="submit" class="btn btn-primary" id="save">选取</button>
            </div>
        </div>
    </div>
</div>
        
<script type="text/javascript" src="//cdn.bootcss.com/select2/4.0.3/js/select2.min.js"></script>
<script type="text/javascript" src="/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" src="//cdn.bootcss.com/jquery-validate/1.15.0/jquery.validate.min.js"></script>
<script type="text/javascript" src="/js/goods-edit.js"></script>
<script>
	$(document).ready(function(){
		$('.checkbox.inline').click(function(){
		  $("#click").toggle();
		  });
		});
	
	$(".zdsp").click(function(){
		$('#tk').show();
	})
	
	$(".yc").click(function(){
		$('#tk').hide();
	})
	
	function formatter_title(val, row, index){
		var pic_url = row.pic_url.indexOf("cbu01.alicdn.com") ? row.pic_url : row.pic_url;
		var html = '<a href="'+row.pic_url+'" target="_blank" style="float:left;"><img src="'+pic_url+'" style="width:64px; height:64px;"></a>';
		html += '<div style="height:64px;margin-left: 74px;overflow:hidden;"><p class="goods-title"><a href="/h5/goods?id='+row.id+'" target="_blank">'+row.title+'</a></p>';
		html += '<span class="goods-price">￥'+row.price+'</span>';
		return html+'</div>';
	}
	
	$('#save').click(function(){
		var ids = '';
	        $('.selected').each(function(e, item){
	        	ids += ','+$(this).attr('data-uniqueid');
	        }); 
	         $.ajax({
	        	type: "POST",
	            url: "/coupon/specified",
	            data: "id="+ids+"",
	            dataType: "json",
	            success: function(){
	              
	            }
	        }) 
	            
	})
	
	
	

</script>
